package com.situ.boot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.boot.entity.Student;
import com.situ.boot.service.IStudentService;

@Controller
@RequestMapping("/student")
public class StudentController {
	@Autowired
	private IStudentService studentService;
	
	@RequestMapping("/list")
	public String list(Model model) {
		List<Student> list = studentService.selectAll();
		model.addAttribute("list", list);
		return "list"; 
	}
	
	@RequestMapping("/deleteById")
	public String deleteById(Integer id) {
		studentService.deleteById(id);
		return "redirect:/student/list";
	}
	
}
